//
//  Copyright: (C) 2006-2008 by Kandalu Software 
//  London
//  info@kandalu.net
//

#import "CustomDocumentController.h"
#import "Globals.h"
#import "ApplicationDefaults.h"


@implementation CustomDocumentController

#pragma mark Class Object Initializer

+ (void)initialize
{
  NSLog(@"!!!------------------------------!!!\n");
  NSLog(@"!!!---  STARTING K Kitchen  ---!!!\n");
  NSLog(@"!!!------------------------------!!!\n");
  NSLog(@"\n");
  [ApplicationDefaults registerInitialUserDefaults];
}


#pragma mark Overwriting NSDocumentController methods


/*(1)*/- (id)openUntitledDocumentAndDisplay:(BOOL)displayDocument error:(NSError **)outError
{
  *outError = nil;
  [self showStartingPointsWindow:self];
  return nil;
}
/*(2)*/


- (BOOL)presentError:(NSError *)error
{
  return error &&
         !([error domain] == NSCocoaErrorDomain && 
         [error code] == 260); // eat error message "No document created"
}

- (NSString *)defaultType
{
  return @""; // return anything non-nil here, 
              // so that openUntitledDocumentAndDisplay:error: will be called
}

#pragma mark IB Actions for Starting Points Panel

- (IBAction)showStartingPointsWindow:(id)sender
{
  [_startingPointsWindowController showStartingPointsWindow:sender];
}

- (IBAction)goToKKitchenWebpage:(id)sender
{
  [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:KKHomePageURL]];
}

- (IBAction)goToBuyWebpage:(id)sender
{
  [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:KKBuyPageURL]];
}

#pragma mark Further IB Actions 



@end
